package mud.storage;

import static java.lang.System.out;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Database {
	String driver = "com.mysql.jdbc.Driver";
	String url = "jdbc:mysql://192.168.1.131/storage";
	String user = "pub";
	String passwd = "pub";

	Connection conn = null;
	Statement stmt = null;
	ResultSet rs = null;

	public Database() throws ClassNotFoundException, SQLException {
		Class.forName(driver);
		conn = DriverManager.getConnection(url, user, passwd);
		stmt = conn.createStatement();
	}

	public void queryStock() throws SQLException {
		String sql = "select date,name,number,provider from td_stock";
		rs = stmt.executeQuery(sql);
		while (rs.next()) {
			out.println(rs.getString("name"));
		}
	}
}
